{extend name='layout'}
{block name="content"}
<div class="container-fluid">
    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-toolbar clearfix">
                    <form class="pull-right search-bar form-inline" method="get" action="" role="form">
                        <div class="form-group">
                            <select class="form-control" id="role_id" name="role_id" size="1">
                                <option value="">所属角色</option>
                                {foreach $roles as $role}
                                    <option value="{$role.id}" {if $request->get("role_id") eq $role.id}selected{/if}>{$role.name}</option>
                                {/foreach}
                            </select>
                        </div>
                        <div class="form-group">
                            <input type="text" class="form-control" value="{$request->get('username')}" name="username" placeholder="用户名模糊搜索">
                        </div>
                        <div class="form-group">    
                            <input class="btn btn-primary m-r-5" type="submit" value="搜索"/>
                        </div>
                    </form>
                    <div class="toolbar-btn-action">
                        <a class="btn btn-primary m-r-5" data-modal="{:url('add')}" data-title="新增用户"><i class="mdi mdi-plus"></i> 新增用户</a>
                    </div>
                </div>
                <div class="card-body">

                    <div class="table-responsive">
                        <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>编号</th>
                                    <th>用户名称</th>
                                    <th>所属角色</th>
                                    <th>创建时间</th>
                                    <th>更新时间</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php if (!$list->isEmpty()): foreach ($list as $item): ?>
                                <tr>
                                    <td>{$item.id}</td>
                                    <td>{$item.username}</td>
                                    <td>{$item.role.name|default='-'}</td>
                                    <td>{$item.create_time}</td>
                                    <td>{$item.update_time}</td>
                                    <td>
                                        {if $item.status}
                                        <span class="label label-success">启用</span>
                                        {else}
                                        <span class="label label-danger">禁用</span>
                                        {/if}
                                    </td>
                                    <td>
                                        <div class="btn-group">
                                            <a class="btn btn-xs btn-primary" data-modal="{:url('edit')}?id={$item.id}" data-title="编辑" title="编辑"
                                                data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>
                                            {if $item.status eq 0}
                                                <a class="btn btn-xs btn-success" data-action="{:url('status')}" data-value="id={$item.id}&status=1" title="启用"
                                                data-toggle="tooltip"><i class="mdi mdi-check"></i></a>
                                            {else/}
                                                <a class="btn btn-xs btn-warning" data-action="{:url('status')}" data-value="id={$item.id}&status=0" title="禁用"
                                                data-toggle="tooltip"><i class="mdi mdi-block-helper"></i></a>
                                            {/if}
                                            <a class="btn btn-xs btn-danger" data-action="{:url('delete')}" data-value="id={$item.id}" title="删除" data-confirm="确认删除该用户？"
                                                data-toggle="tooltip"><i class="mdi mdi-window-close"></i></a>
                                                
                                        </div>
                                    </td>
                                </tr>
                                <?php endforeach; else: ?>
                                <tr>
                                    <td colspan="7">暂无记录</td>
                                </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                    {$list|raw}
                </div>
            </div>
        </div>

    </div>

</div>
{/block}